package cn.javass.framework.web.core;

import java.util.ArrayList;
import java.util.List;

import cn.javass.framework.aop.interceptor.Interceptor;

public class ActionInvocation {
	List<Interceptor> interceptors = new ArrayList<Interceptor>();
	Action action ;
	String resultCode ;
	public void execute() throws Exception{
		for(Interceptor inter: interceptors){
			inter.before(Action.class.getMethod("execute"),null,action);
		}
		String resultCode = getAction().execute();
		
		for(Interceptor inter: interceptors){
			inter.after(Action.class.getMethod("execute"),null,action);
		}
		this.resultCode = resultCode;
	}
	
	public Action getAction() {
		return action;
	}
	public void setAction(Action action) {
		this.action = action;
	}
	
	public String getResult(){
		return ActionServlet.appCtx.getResult(action,resultCode);
	}


	public void setInterceptors(List<Interceptor> interceptors) {
		this.interceptors = interceptors;
	}
	
}
